using System.Collections.Generic;

namespace Magiq.Tests.TestModel
{
    public class TestDomain<TTestClass> : ITestDomain<TTestClass> where TTestClass : class, ITestClass<TTestClass>, new()
    {
        public TestDomain()
        {
            TestClassInstances = new List<TTestClass>();
            ReferenceClassInstances = new List<ReferenceTestClass>();

            for (var i = 10; i < 15; i++)
            {
                ReferenceClassInstances.Add(new ReferenceTestClass
                                                {
                                                    StringProperty = "test" + i,
                                                    IntProperty = i
                                                });
            }
            for (var i = 100; i < 117; i++)
            {
                ReferenceClassInstances.Add(new ReferenceTestClass
                                                {
                                                    StringProperty = "lolo",
                                                    IntProperty = i
                                                });
            }


            for (var i = 0; i < 7; i++)
            {
                TestClassInstances.Add(new TTestClass
                                           {
                                               StringProperty = "test" + i,
                                               IntProperty = i,
                                               Reference = ReferenceClassInstances[i],
                                               AnotherIntProperty = i + 2,
                                               AnotherStringProperty = "pepe" + i,
                                               NullableIntProperty = i % 2 == 0 ? i : (int?)null,
                                           });
            }

            for (var i = 8; i < 10; i++)
            {
                TestClassInstances.Add(new TTestClass
                                           {
                                               StringProperty = "test" + i,
                                               IntProperty = i,
                                               Reference = ReferenceClassInstances[i],
                                               AnotherIntProperty = i + 2,
                                               AnotherStringProperty = "pepe" + i,
                                               NullableIntProperty = i % 2 == 0 ? i : (int?)null
                                           });
            }

            for (var i = 0; i < 5; i++)
            {
                TestClassInstances.Add(new TTestClass
                                           {
                                               StringProperty = "sarasa",
                                               IntProperty = i,
                                               Reference = ReferenceClassInstances[i],
                                               NullableIntProperty = i % 2 == 0 ? i : (int?)null,
                                               AnotherIntProperty = i + 1,
                                               AnotherStringProperty = "qwerty",
                                               SelfReference = TestClassInstances[i]
                                           });
            }
            for (var i = 8; i < 15; i++)
            {
                TestClassInstances.Add(new TTestClass
                                           {
                                               StringProperty = "sarasa",
                                               IntProperty = i,
                                               Reference = ReferenceClassInstances[i],
                                               NullableIntProperty = i % 2 == 0 ? i : (int?)null,
                                               AnotherIntProperty = i + 1,
                                               AnotherStringProperty = "qwerty"
                                           });
            }
            TestClassInstances.Add(new TTestClass
                                       {
                                           StringProperty = "sarasa",
                                           IntProperty = 5,
                                           Reference = ReferenceClassInstances[4],
                                           NullableIntProperty = 2,
                                           AnotherIntProperty = 4,
                                           AnotherStringProperty = "sarasala"
                                       });
            TestClassInstances.Add(new TTestClass
                                       {
                                           StringProperty = "sarasa",
                                           IntProperty = 5,
                                           Reference = ReferenceClassInstances[4],
                                           NullableIntProperty = 2,
                                           AnotherIntProperty = 4,
                                           AnotherStringProperty = "sarasala"
                                       });
            TestClassInstances.Add(new TTestClass
                                       {
                                           StringProperty = null,
                                           IntProperty = 5,
                                           Reference = null,
                                           NullableIntProperty = null,
                                           AnotherIntProperty = 4,
                                           AnotherStringProperty = "sarasala"
                                       });
            TestClassInstances.Add(new TTestClass
                                       {
                                           StringProperty = null,
                                           IntProperty = 5,
                                           Reference = null,
                                           NullableIntProperty = null,
                                           AnotherIntProperty = 4,
                                           AnotherStringProperty = "sarasala"
                                       });
        }

        public List<TTestClass> TestClassInstances { get; private set; }

        public List<ReferenceTestClass> ReferenceClassInstances { get; private set; }
    }
}